public class Link {
	
	public String href { get; set; }
	public String rel { get; set; }
	public String ltype { get; set; }
	public String hreflang { get; set; }
	public String title { get; set; }
	public String length { get; set; }
	
	public Link() {
	}
	
	public Link(XmlStreamReader reader) {
		Integer aCount = reader.getAttributeCount();
		for (Integer i=0;i<aCount;i++) {
			String aname = reader.getAttributeLocalName(i);
			String avalu = reader.getAttributeValueAt(i);
			if (aname == 'href') {
				href = avalu;
			} else if (aname == 'rel') {
				rel = avalu;
			} else if (aname == 'type') {
				ltype = avalu;
			} else if (aname == 'hreflang') {
				hreflang = avalu;
			} else if (aname == 'title') {
				title = avalu;
			} else if (aname == 'length') {
				length = avalu;
			}
		}
		reader.next();
	}
	
	public String toAPP() {
		String output = '<link ';
		if (href != null) output += 'href="' + href + '" ';
		if (rel != null) output += 'rel="' + rel + '" ';
		if (ltype != null) output += 'type="' + ltype + '" ';
		if (hreflang != null) output += 'hreflang="' + hreflang + '" ';
		if (title != null) output += 'title="' + title + '" ';
		if (length != null) output += 'length="' + length + '" ';
		output += ' />\n';
		return output;
	}
}